//package read.niit.mock
//
//import java.util.{Properties, Random}
//
//import org.apache.kafka.clients.producer.{KafkaProducer, ProducerConfig, ProducerRecord}
//import org.apache.kafka.common.serialization.StringSerializer
//import read.niit.mock.Simulator.arr5
//
//import scala.collection.mutable.{ArrayBuffer, ListBuffer}
//
//object MockData {
//
//  def main(args: Array[String]): Unit = {
//
//    // 生成模拟数据
//    // 格式 ：timestamp grade major  studentid   read_subject    date  bookid
//    // 含义： 时间戳    年级  专业    学生     阅读类别         日期      书
//
//    // Application => Kafka => SparkStreaming => Analysis
//    val prop = new Properties()
//    // 添加配置
//    prop.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "node1:9092")
//    prop.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
//    prop.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
//    val producer = new KafkaProducer[String, String](prop)
//
////    while ( true ) {
//      mockdata().foreach(
//        data => {
//            // 向Kafka中生成数据
//            val record = new ProducerRecord[String, String]("RD2", data)
//            producer.send(record)
////            println(data)
//        }
//      )
//
//      Thread.sleep(2000)
//    }
//
////  }
//
//
//  def mockdata() = {
//    val list = ListBuffer[String]()
//
//    val dateList = ListBuffer[String]("4.22", "4.23")
//
//    val gradeList = ListBuffer[String]("大一", "大二", "大三","大四")
//    val majorList = ListBuffer[String]("计算机科学与技术", "医学专业", "金融学专业","师范类专业", "艺术类专业")
//    val read_subjectList = ListBuffer[String]("时事政治类书籍", "文学小说类书籍", "历史传记类书籍","哲学宗教类书籍",
//      "旅游地理类书籍", "经管类书籍","法律类书籍", "国防军事类书籍", "艺术鉴赏类书籍", "体育运动类书籍","健康保健类书籍",
//      "娱乐休闲类书籍", "考试考证类书籍", "科技类书籍", "心理成长类书籍")
//    var student_id = 20160000
//   for(i <- 1 to 9999){
//      student_id += 1
//      val date = dateList(new Random().nextInt(2))
//      val grade = gradeList(new Random().nextInt(4))
//      val major = majorList(new Random().nextInt(5))
//      val read_subject = read_subjectList(new Random().nextInt(15))
//      list.append(s"${System.currentTimeMillis()} ${student_id} ${date} ${grade} ${major} ${read_subject}")
//      var data=list.tail
//      println(data)
//      data:ListBuffer[String] =>{
//        val record = new ProducerRecord[String, String]("RD2", data)
//     }
//    }
//    list
//  }
//
//}
